package com.fixme4trade.persistence;

import java.util.List;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.slf4j.Logger;

import com.fixme4trade.domain.Customer;
import com.fixme4trade.domain.Product;
import com.fixme4trade.domain.Sell;
import com.fixme4trade.domain.User;

import br.gov.frameworkdemoiselle.stereotype.PersistenceController;
import br.gov.frameworkdemoiselle.template.JPACrud;

@PersistenceController
public class SellDAO extends JPACrud<Sell, Long> {
	
	private static final long serialVersionUID = 1L;

	@Inject
	@SuppressWarnings("unused")
	private Logger logger;
	
	@Inject
	private EntityManager em;
		
	public List<Sell> getShoppingCart(Customer customer) {
		Query query = em.createNativeQuery(
				//"SELECT s FROM Sell s", Sell.class);
				//"SELECT * FROM Sell", Sell.class);
				"SELECT * FROM Sell s WHERE s.customer_id="+customer.getId()+" AND s.payment_id IS NULL", Sell.class);			
		
		return query.getResultList();
	}
	
}
